package com.xzc.lease.common.utils;

import java.util.Random;

/**
 * @author 徐生
 * 2024/10/13
 * description: 用于获取随机验证码
 */
public class CodeUtil {

    public static String getRandomCode(Integer length){ //length：指定验证码的长度
        //用于拼接随机生成的数字，并返回
        StringBuilder builder = new StringBuilder();
        Random random = new Random();
        for (Integer i = 0; i < length; i++) {
            //生成0~9之间的数字
            int num = random.nextInt(10);
            builder.append(num);
        }

        return builder.toString();
    }
}
